package threads;
/**
 * 
 * All runnables inherit from this class,   
 * This ensures that all Runnables have a stop-method and a stop-variable,  which makes it possible to escape/terminate Runnables in safe places and hence make sure they alter no data after they have been told to stop whatever they're doing.
 *@implements Runnable
 */
public class BaseRunnableBCBS implements Runnable  {
	/**
	 * If this boolean becomes true at any point, the Runnable will not continue from the point where this boolean is checked. This way all threads can safely be escaped.
	 */
	protected boolean stop = false;
	
	/**
	 * Sets the stop-variable to true for the runnable, causing any methods within a subclass to stop, if defined properly.
	 */
	public void stop() {
		stop = true;
	}

	@Override
	/**
	 * This method is always overridden and contains whatever code the subclass must execute as a runnable.
	 */
	public void run() {
		// must be overridden by extensions
		
	}

}
